<table class="table table-hover">
    <thead>
    <tr>
        <th>开始日期</th>
        <th>截止日期</th>
        <th>文件类型</th>
        <th>文件名</th>
        <th>操作人</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    @foreach($paginator as $row)
        <tr>
            <td>{{ $row->start_date }}</td>
            <td>{{ $row->end_date }}</td>
{{--            <td>{{ \App\Models\SalesReport\SVExportFile::$_fileType[$row->file_type] }}</td>--}}
            <td>{{ $row->file_type }}</td>
            <td>{{ $row->file_name }}</td>
            <td>{{ \App\Util\User::getUsernameById($row->user_id) }}</td>
            <td>
                <a target="_blank" href="/xqc/sales-report/sv-export-download?id={{ $row->id }}" class="btn btn-xs btn-default"><i class="fa fa-download"></i> 下载</a>
                <a href="javascript:void(0);" data-id="{{ $row->id }}" class="btn btn-xs btn-danger grid-row-delete"><i class="fa fa-trash"></i> 删除</a>
            </td>
        </tr>
    @endforeach
    </tbody>
</table>
<script language="JavaScript" type="text/javascript">
    $(function () {
        $('.grid-row-delete').unbind('click').click(function(e) {
            e.preventDefault();
            var id = $(this).data('id');
            swal({
                title: "确定删除？",
                text : "确定要删除此文件吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确认",
                showLoaderOnConfirm: true,
                cancelButtonText: "取消",
                preConfirm: function() {
                    return new Promise(function(resolve) {
                        $.ajax({
                            method: 'post',
                            url: '/xqc/sales-report/sv-export/' + id,
                            data: {
                                _token: "{{ csrf_token() }}",
                                _method:'delete',
                            },
                            success: function (data) {
                                resolve(data);
                            }
                        });
                    });
                }
            }).then(function(result) {
                var data = result.value;
                if (typeof data === 'object') {
                    if (data.status) {
                        toastr.success(data.message);
                        $.pjax.reload('#pjax-container');
                    } else {
                        swal(data.message, '', 'error');
                    }
                }
            });
        });
    });
</script>
